<?php

    $name = $_GET['userName'];
    $pass = $_GET['password'];
    require('db_connection.php');

$query = "SELECT userType FROM tbladmin WHERE userName like '$name' AND password like '$pass'";
    $result = mysql_query($query);

  while ($row = mysql_fetch_array($result))
    {
      $userType = $row['userType'];
      //echo $row['userType'];
    }


if($userType == 'admin')
{

    setcookie("userName",$name);
    setcookie("password",$pass);
    $host  = $_SERVER['HTTP_HOST'];
    $uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = 'main.php';
    header("Location: http://$host$uri/$extra");
}
if($userType == 'superadmin')
{
    setcookie("userName",$name);
    setcookie("password",$pass);

    $host  = $_SERVER['HTTP_HOST'];
    $uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = 'main.php';
    header("Location: http://$host$uri/$extra");

}

if($userType == '')
{
    require('index.php');
}


?>


